import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';

void main() {
  const MethodChannel channel = MethodChannel('flutter_openim_sdk');

  TestWidgetsFlutterBinding.ensureInitialized();

  setUp(() {
    channel.setMockMethodCallHandler((MethodCall methodCall) async {
      switch (methodCall.method) {
        case 'initSDK':
            return {'result': true,};
          case 'login':
            return {'result': true};
          case 'getLoginStatus':
            return {'result': true};
        default:
          return null;
      }
    });
  });

  tearDown(() {
    channel.setMockMethodCallHandler(null);
  });

  test('checkVerifyEnable', () async {
    final result = await OpenIM.iMManager.initSDK();
    expect(result['result'], isTrue);
  });
  test('isInitSuccess', () async {
    final result = await OpenIM.iMManager.login();
    expect(result['result'], isTrue);
  });
  test('getToken', () async {
    final result = await OpenIM.iMManager.getLoginStatus();
    expect(result['result'], isTrue);
  });
}

